{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Dynamic Process: Robustness to the Distribution of Preference Intensities (C.3)" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "ExecuteTime": { "end_time": "2021-02-09T13:45:47.970067Z", "start_time": "2021-02-09T13:45:41.514789Z" } }, "outputs": [], "source": [ "import pandas as pd\n", "from poisson_approval import *" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "ExecuteTime": { "end_time": "2021-02-09T13:45:47.978333Z", "start_time": "2021-02-09T13:45:47.973346Z" } }, "outputs": [], "source": [ "N_SAMPLES = 10000\n", "N_MAX_EPISODES = 1000" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "ExecuteTime": { "end_time": "2021-02-09T13:45:48.010248Z", "start_time": "2021-02-09T13:45:47.981427Z" } }, "outputs": [], "source": [ "distributions = {\n", " 'U([0.09, .11])': RandProfileNoisyDiscreteUniform(\n", " types=[(ranking, 0.1, 0.01) for ranking in RANKINGS]),\n", " 'U([0.89, .91])': RandProfileNoisyDiscreteUniform(\n", " types=[(ranking, 0.9, 0.01) for ranking in RANKINGS]),\n", "}" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Condorcet Consistency" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "ExecuteTime": { "end_time": "2021-02-09T13:45:49.661510Z", "start_time": "2021-02-09T13:45:48.014239Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
ApprovalPluralityAnti-plurality
rho_o
U([0.09, .11])0.9848000.66490.492624
U([0.89, .91])0.9849750.66000.489420
\n", "
" ], "text/plain": [ " Approval Plurality Anti-plurality\n", "rho_o \n", "U([0.09, .11]) 0.984800 0.6649 0.492624\n", "U([0.89, .91]) 0.984975 0.6600 0.489420" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "table_cond = pd.DataFrame()\n", "table_cond.index.name = 'rho_o'\n", "for distribution_name, distribution in distributions.items():\n", " rand_profile = RandConditional(\n", " distribution, \n", " test=is_condorcet, n_trials_max=None\n", " )\n", " results = monte_carlo_fictitious_play(\n", " factory=rand_profile,\n", " n_samples=N_SAMPLES,\n", " n_max_episodes=N_MAX_EPISODES,\n", " voting_rules=VOTING_RULES,\n", " init='random_tau',\n", " monte_carlo_settings=[\n", " MCS_FREQUENCY_CW_WINS,\n", " ],\n", " file_save='sav/distribution_%s_with_CW.sav' % distribution_name,\n", " )\n", " for voting_rule in VOTING_RULES:\n", " table_cond.loc[distribution_name, voting_rule] = float(results[voting_rule]['mean_frequency_cw_wins'])\n", "table_cond" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Welfare Loss" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "ExecuteTime": { "end_time": "2021-02-09T13:45:51.128669Z", "start_time": "2021-02-09T13:45:49.666359Z" }, "scrolled": true }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
ApprovalPluralityAnti-plurality
rho_o
U([0.09, .11])0.0108980.0858090.115399
U([0.89, .91])0.0330060.0619980.113344
\n", "
" ], "text/plain": [ " Approval Plurality Anti-plurality\n", "rho_o \n", "U([0.09, .11]) 0.010898 0.085809 0.115399\n", "U([0.89, .91]) 0.033006 0.061998 0.113344" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "table_welfare_loss = pd.DataFrame()\n", "table_welfare_loss.index.name = 'rho_o'\n", "for distribution_name, distribution in distributions.items():\n", " results = monte_carlo_fictitious_play(\n", " factory=distribution,\n", " n_samples=N_SAMPLES,\n", " n_max_episodes=N_MAX_EPISODES,\n", " voting_rules=VOTING_RULES,\n", " init='random_tau',\n", " monte_carlo_settings=[\n", " MCS_WELFARE_LOSSES,\n", " ],\n", " file_save='sav/distribution_%s.sav' % distribution_name,\n", " )\n", " for voting_rule in VOTING_RULES:\n", " table_welfare_loss.loc[distribution_name, voting_rule] = float(\n", " results[voting_rule]['mean_utilitarian_welfare_loss'])\n", "table_welfare_loss" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.7" }, "toc": { "base_numbering": 1, "nav_menu": {}, "number_sections": true, "sideBar": true, "skip_h1_title": true, "title_cell": "Table of Contents", "title_sidebar": "Contents", "toc_cell": false, "toc_position": {}, "toc_section_display": true, "toc_window_display": false } }, "nbformat": 4, "nbformat_minor": 4 }